package vip.gnloypp.redis.mq.api.core.base;

import cn.hutool.core.lang.Assert;
import lombok.extern.log4j.Log4j2;
import vip.gnloypp.redis.mq.api.data.RedisMqConstant;

import java.util.Map;
import java.util.Optional;

/**
 * @author GuoNanLin
 * @since 2024/9/3 9:44
 */
@Log4j2
public class LogManager {

    private final String logPrefix;

    public LogManager(String logPrefix) {
        this.logPrefix = Optional.ofNullable(logPrefix).orElse(RedisMqConstant.DEFAULT_LOG_PREFIX);
    }

    public void info(String message, Object... params) {
        log.info(logPrefix + message, params);
    }

    public void warn(String message, Object... params) {
        log.warn(logPrefix + message, params);
    }

    public void error(String message, Object... params) {
        log.error(logPrefix + message, params);
    }

    public void notNull(Object object, String message, Object... params) {
        Assert.notNull(object, logPrefix + message, params);
    }

    public void notBlank(CharSequence text, String message, Object... params) {
        Assert.notBlank(text, logPrefix + message, params);
    }

    public void notEmpty(Iterable<?> collection, String message, Object... params) {
        Assert.notEmpty(collection, logPrefix + message, params);
    }

    public void notEmpty(Map<?, ?> map, String message, Object... params) {
        Assert.notEmpty(map, logPrefix + message, params);
    }

}
